package com.vincent.suchao.lcld;

import com.vincent.suchao.adapter.ContactsAdapter;
import com.vincent.suchao.adapter.NineMenuAdapter;
import com.vincent.suchao.adapter.YWJSAdapter;
import com.vincent.suchao.entity.MyContacts;
import com.vincent.suchao.entity.MyContacts.ContactItem;
import com.vincent.suchao.entity.NineMenuItem;
import com.vincent.suchao.util.MyGallery;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class YWJS_Activity extends Activity implements OnClickListener, OnItemClickListener {
	private TextView tv_tittle, tv_ywjs;
	private Button b_back, ywjs_btn1, ywjs_btn2, ywjs_btn3;
	private MyGallery g_list;
	private YWJSAdapter adpter;
	private ImageView iv_ywjs_line, iv_ywjs_icon;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_ywjs);
		init();
	}

	private void init() {
		tv_ywjs = (TextView) findViewById(R.id.tv_ywjs);
		iv_ywjs_line = (ImageView) findViewById(R.id.iv_ywjs_line);

		iv_ywjs_icon = (ImageView) findViewById(R.id.iv_ywjs_icon);
		tv_tittle = (TextView) findViewById(R.id.tv_tittle);
		tv_tittle.setText(getString(R.string.menu_com_ywjs));
		b_back = (Button) findViewById(R.id.b_back);
		b_back.setOnClickListener(this);
		g_list = (MyGallery) findViewById(R.id.g_list);
		adpter = new YWJSAdapter(this);
		g_list.setAdapter(adpter);
		g_list.setSelection(0);

		g_list.setOnItemClickListener(this);
		ywjs_btn1 = (Button) findViewById(R.id.ywjs_btn1);
		ywjs_btn2 = (Button) findViewById(R.id.ywjs_btn2);
		ywjs_btn3 = (Button) findViewById(R.id.ywjs_btn3);
		ywjs_btn1.setOnClickListener(this);
		ywjs_btn2.setOnClickListener(this);
		ywjs_btn3.setOnClickListener(this);

		tv_ywjs.setText(R.string.ywjs_cotent1);
		g_list.setVisibility(View.VISIBLE);
		iv_ywjs_line.setVisibility(View.VISIBLE);
		ywjs_btn1.setBackgroundResource(R.drawable.ywjs_btn1_tap);
		ywjs_btn2.setBackgroundResource(R.drawable.selector_ywjs_btn2);
		ywjs_btn3.setBackgroundResource(R.drawable.selector_ywjs_btn3);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.gsjj, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {

		case R.id.b_back:
			finish();
			break;
		case R.id.ywjs_btn1:
			tv_ywjs.setText(R.string.ywjs_cotent1);
			g_list.setVisibility(View.VISIBLE);
			iv_ywjs_line.setVisibility(View.VISIBLE);
			iv_ywjs_icon.setVisibility(View.GONE);
			ywjs_btn1.setBackgroundResource(R.drawable.ywjs_btn1_tap);
			ywjs_btn2.setBackgroundResource(R.drawable.selector_ywjs_btn2);
			ywjs_btn3.setBackgroundResource(R.drawable.selector_ywjs_btn3);
			break;
		case R.id.ywjs_btn2:
			tv_ywjs.setText(R.string.ywjs_cotent2);
			g_list.setVisibility(View.GONE);
			iv_ywjs_line.setVisibility(View.GONE);
			iv_ywjs_icon.setVisibility(View.GONE);
			ywjs_btn1.setBackgroundResource(R.drawable.selector_ywjs_btn1);
			ywjs_btn2.setBackgroundResource(R.drawable.ywjs_btn2_tap);
			ywjs_btn3.setBackgroundResource(R.drawable.selector_ywjs_btn3);
			break;
		case R.id.ywjs_btn3:
			tv_ywjs.setText(R.string.ywjs_cotent3);
			g_list.setVisibility(View.GONE);
			iv_ywjs_line.setVisibility(View.GONE);
			iv_ywjs_icon.setVisibility(View.GONE);
			ywjs_btn1.setBackgroundResource(R.drawable.selector_ywjs_btn1);
			ywjs_btn2.setBackgroundResource(R.drawable.selector_ywjs_btn2);
			ywjs_btn3.setBackgroundResource(R.drawable.ywjs_btn3_tap);
			break;
		default:
			break;
		}

	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		iv_ywjs_icon.setVisibility(View.VISIBLE);
		switch (arg2) {
		case 0:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon1);
			tv_ywjs.setText(R.string.ywjs_icon_1);
			break;
		case 1:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon2);
			tv_ywjs.setText(R.string.ywjs_icon_2);
			break;
		case 2:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon3);
			tv_ywjs.setText(R.string.ywjs_icon_3);
			break;
		case 3:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon4);
			tv_ywjs.setText(R.string.ywjs_icon_4);
			break;
		case 4:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon5);
			tv_ywjs.setText(R.string.ywjs_icon_5);
			break;
		case 5:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon6);
			tv_ywjs.setText(R.string.ywjs_icon_6);
			break;
		case 6:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon7);
			tv_ywjs.setText(R.string.ywjs_icon_7);
			break;
		case 7:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon8);
			tv_ywjs.setText(R.string.ywjs_icon_8);
			break;
		case 8:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon9);
			tv_ywjs.setText(R.string.ywjs_icon_9);
			break;
		case 9:
			iv_ywjs_icon.setBackgroundResource(R.drawable.ywjs_icon10);
			tv_ywjs.setText(R.string.ywjs_icon_10);
			break;
		default:
			break;
		}
	}

}
